/**
 *  StackFrame.java : IceBird project
 *  14:41:16 
 */
package icebird.compiler.ncomp;

/**
 * @author Sergey Shulepoff[Knott]
 */
public final class StackFrame {

	private Label footer;
	
	private X86Assembler asm;
	
	public StackFrame() {
		asm = X86Assembler.getAsm();
		footer = new Label(".footer");
	}
	
	public void emitHeader() {
		asm.push(X86Register.EBP);
		asm.move(X86Register.EBP, X86Register.ESP);
	}
	
	public void emitTrailer() {
		asm.bind(footer);
		
		asm.lea(X86Register.ESP, X86Register.EBP, 4);
		asm.pop(X86Register.EBP);
		
		asm.ret();
	}
	
	public void emitReturn() {
		asm.jmp(footer);
	}
}
